package Pack;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.*;

public class Testes {
	
	public static void main(String[] args) throws IOException {
		JFrame janela = new JFrame();
		
		JLabel lbFoto;;
		
		JFileChooser fileChooser = new JFileChooser();
		if(fileChooser.showOpenDialog(janela) == JFileChooser.APPROVE_OPTION){
			BufferedImage imagem = ImageIO.read(fileChooser.getSelectedFile());		
			int novaLargura = 141, novaAltura = 150;
			BufferedImage new_img = new BufferedImage(novaLargura,novaAltura, BufferedImage.TYPE_INT_RGB);
			Graphics2D g = new_img.createGraphics();
			g.drawImage(imagem, 0, 0, novaLargura,novaAltura, null);
			ImageIO.write(new_img, "JPG", new File("imagens/back.jpg"));
			
			lbFoto = new JLabel(new ImageIcon("imagens/back.jpg"));
			janela.add(lbFoto);
			janela.setVisible(true);
		}else{
			System.out.println("cancela");
		}
		

	}

}
